package frame;

import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JTextPane;

import menus.AwesomeMenuBar;
import misc.Vals;

import textArea.AwesomeTextPanel;
import textArea.KeyEventHandler;


public class AwesomeFrame extends JFrame {
	
	/**
	 * Keeps track of column mode
	 */
	public boolean isInColumnMode=false;
	
	private AwesomeTextPanel textPanel;
	private AwesomeMenuBar menuBar;
	private JFileChooser fileChooser;
	private File currFile;
	
	public AwesomeFrame() {
		super(Vals.mainFrameTitle);
		this.initComponents();
	}
	
	private void initComponents() {
		// Initialize the text panel
		this.textPanel = new AwesomeTextPanel();
		this.setContentPane(textPanel);
		this.textPanel.getTextPane().addKeyListener(new KeyEventHandler());
		
		// Initialize the Menu Bar
		this.menuBar = new AwesomeMenuBar();
		this.setJMenuBar(menuBar);
		
		// Initialize the file chooser
		this.fileChooser = new JFileChooser();
	}
	
	/**
	 * Returns the currently selected AwesomeTextPanel.
	 * @return the currently selected AwesomeTextPanel.
	 */
	public AwesomeTextPanel getTextPanel() {
		return this.textPanel;
	}
	
	/**
	 * Returns the textPane of the currently selected AwesomeTextPanel.
	 * @return the textPane of the currently selected AwesomeTextPanel.
	 */
	public JTextPane getTextPane() {
		return this.textPanel.getTextPane();
	}
	
	/**
	 * Returns the file chooser.
	 * @return the file chooser.
	 */
	public JFileChooser getFileChooser() {
		return this.fileChooser;
	}
	
	/**
	 * Returns the current file used to save the document.
	 * @return the current file used to save the document.
	 */
	public File getCurrentFile() {
		return this.currFile;
	}
	
	/**
	 * Sets the current file used to save the document.
	 * @param file the file to use.
	 */
	public void setCurrentFile(File file) {
		this.currFile = file;
	}
	
}
